<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>自定义表单设置公开</title>
    <#include "/pubHeadStyle.html">
</head>
<body>
<div>
    <form class="layui-form">
        <div class="layui-btn-container" style="position: absolute;bottom: 0;left:34%">
            <span class="layui-btn layui-btn-sm" lay-submit lay-filter="formPublic" id="editFieldButton">保存</span>
            <button class="layui-btn layui-btn-sm layui-btn-danger" id="setPublicClose">关闭</button>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">表单权限 </label>
            <div class="layui-input-block">
                <input class="" type="radio" name="isPublic" value="1" title="公开">
                <input class="" type="radio" name="isPublic" value="0" title="未公开">
            </div>
        </div>
    </form>
</div>
<script src="${ctx}/extends/jquery.min.js" type="text/javascript"></script>
<script>
    layui.config({
        base: serverPath.formPath + staticPath.formPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','form','setter','jquery'],function () {
        var form=layui.form,setter=layui.setter,$=layui.jquery;
        var isPublic='${isPublic}';
        var formDefId='${formDefId}';
        $("input[name='isPublic'][value='0']").attr("checked",isPublic === '0');
        $("input[name='isPublic'][value='1']").attr("checked",isPublic === '1');
        form.render();

        form.on('submit(formPublic)',function () {
            isPublic=$("input[type='radio'][name='isPublic']:checked").val();
            $.ajax({
                url: serverPath.formPath + setter.formLinkPath +"formDef/setPublic",
                data: {"formDefId": formDefId,"isPublic":isPublic},
                dataType:'json',
                contextType:'json',
                success: function (data) {
                    parent.layui.table.reload('customVersion');
                    var index=parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.layer.msg(data.msg);
                }
            });
            return false;
        });
    });
    $("#setPublicClose").click(function () {
        var index=parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    });
</script>
</body>
</html>